<#-- 导入模版定义文件-->
<#include "../template/template_listPage.ftl">
<@header title="进货源管理">
<style type="text/css">
    .table {
        padding: 1px;
        text-align: center;
    }
</style>
<script type="text/javascript">
    function query() {
        $('#listForm').submit();
    }
    function saleStaticstics() {
        // window.open("${web_base}/recharge/card_management!saleStatistics.htm");
        ymPrompt.win('${web_base}/recharge/card_management!saleStatistics.htm', 600, 400, '销量统计', null, null, null, {id:'a'});
    }
    /**
     * 添加库存
     */
    function add() {
        var name = $('#name').val();
        window.location.href = '${web_base}/recharge/stock_supplier!doAdd.htm' + '?name=' + encodeURI(name);
    }
    function edit(id, inputid) {
        var name = $('#' + inputid).val();
        $.ajax({
            type:"POST",
            url:"${web_base}/recharge/stock_supplier!doEdit.htm",
            data:"name=" + encodeURI(name) + "&id=" + id,
            success:function (msg) {
                if (msg != undefined && msg == 'error') {
                    $.dialog({type: "warn", content: "操作失败!",modal: true, autoCloseTime: 3000});
                }else{
                  //$.dialog({type: "warn", content: "操作成功!",modal: true, autoCloseTime: 3000});
                }
            }
        });
    }
    function deleteStock(id) {
        var result = confirm("你确定要删除吗!");
        if (result) {
            window.location.href = '${web_base}/recharge/stock_supplier!delete.htm' + '?id=' + id;
        }
    }
</script>
</@header>
<body class="list">
<div class="body">
    <div class="listBar">
        <h1><span class="icon">&nbsp;</span>进货源管理&nbsp;<span class="pageInfo">总记录数:<#if page??>${page.rowCount}</#if>
            (共<#if page??>${page.pageCount}</#if>页)</span></h1>
    </div>
<@pageList page=(page!) id="listForm" action="" query="query" isEmpty=true>
    <div class="operateBar">
        <label>进货源名称:</label>
        <input type="text" name="name" value="${name!}" id="name"/>
        <button type="button" onclick="add();">新增</button>
    </div>
    <table class="listTable">
        <tr>
            <th><span class="sort">序号</span></th>
            <th><span class="sort">进货源名称</span></th>
            <th><span class="sort">操作</span></th>
        </tr>
        <#if  page??&&page.list??&&(page.list?size gt 0) >
            <#list page.list as obj>
                <#assign no=obj_index+page.pageSize*(page.currentPage-1)+1>
                <tr>
                    <td>${no!}</td>
                    <td><input type="text" name="" id="supplier_${no!}" value="${obj.name!}"></td>
                    <td><span onclick="edit('${obj.id!}','supplier_${no!}');"
                              class="spanLink">修改</span>&nbsp;&nbsp;<span
                            onclick="deleteStock('${obj.id!}');" class="spanLink">删除</span>
                    </td>
                </tr>
            </#list>
        </#if>
    </table>
</@pageList>
</div>
</body>
</html>